﻿using System;
using System.Collections.Generic;
using Autodesk.Revit.DB;

namespace HYRElectric.WirePlace
{
	internal class EdgePointComparer : IComparer<XYZ>
	{
		public EdgePointComparer(XYSel sel)
		{
			this.sel = sel;
		}

		public int Compare(XYZ pt1, XYZ pt2)
		{
			if (this.sel == XYSel.maxX)
			{
				if (pt1.X < pt2.X)
				{
					return 1;
				}
				if (pt1.X == pt2.X)
				{
					return 0;
				}
				return -1;
			}
			else if (this.sel == XYSel.minX)
			{
				if (pt1.X < pt2.X)
				{
					return -1;
				}
				if (pt1.X == pt2.X)
				{
					return 0;
				}
				return 1;
			}
			else if (this.sel == XYSel.maxY)
			{
				if (pt1.Y < pt2.Y)
				{
					return 1;
				}
				if (pt1.Y == pt2.Y)
				{
					return 0;
				}
				return -1;
			}
			else
			{
				if (pt1.Y < pt2.Y)
				{
					return -1;
				}
				if (pt1.Y == pt2.Y)
				{
					return 0;
				}
				return 1;
			}
		}

		private XYSel sel;
	}
}
